import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';

import JJHomepageService from './service/homepageService/JJHomepageService'

class App extends Component {

  constructor(props) {
    super(props);

    const data = {title: 'and save to reload.'}
    this.state = {...data}
  }

  componentDidMount(){
    const me = this
    JJHomepageService.requestGetWeather((isSuccess, value, otherInfo) => {
      let data = {}
      data.title = value.errMsg
      me.setState({...data});
    }, (error, otherInfo) => {
      let data = {}
      data.title = error.errMsg
      me.setState({...data});
    })
  }

  render() {
    const {title} = this.state
    return (
      <div className="App">
        <header className="App-header">
          <img src={logo} className="App-logo" alt="logo" />
          <p>
            Edit <code>src/App.js</code> {title}
          </p>
          <a
            className="App-link"
            href="https://reactjs.org"
            target="_blank"
            rel="noopener noreferrer"
          >
            Learn React
          </a>
        </header>
      </div>
    );
  }
}

export default App;
